<template>
  <el-form ref="loginRefForm" :model="userDetail" label-width="120px">
    <el-form-item label="ID">
      <div class="detail">&nbsp;{{userDetail.id}}</div>
    </el-form-item>

    <el-form-item label="账号">
      <div class="detail">&nbsp;{{userDetail.loginAct}}</div>
    </el-form-item>

    <el-form-item label="密码">
      <div class="detail">&nbsp;*********</div>
    </el-form-item>

    <el-form-item label="姓名">
      <div class="detail">&nbsp;{{userDetail.name}}</div>
    </el-form-item>

    <el-form-item label="手机号">
      <div class="detail">&nbsp;{{userDetail.phone}}</div>
    </el-form-item>

    <el-form-item label="邮箱">
      <div class="detail">&nbsp;{{userDetail.email}}</div>
    </el-form-item>

    <el-form-item label="账户是否过期">
      <div class="detail">&nbsp;{{userDetail.accountNoExpired===1 ? '否':'是'}}</div>
    </el-form-item>

    <el-form-item label="密码是否过期">
      <div class="detail">&nbsp;{{userDetail.accountNoExpired===1 ? '否':'是'}}</div>
    </el-form-item>

    <el-form-item label="密码是否锁定">
      <div class="detail">&nbsp;{{userDetail.accountNoLocked===1 ? '否':'是'}}</div>
    </el-form-item>

    <el-form-item label="账号是否启用">
      <div class="detail">&nbsp;{{userDetail.accountEnabled===1 ? '否':'是'}}</div>
    </el-form-item>

    <el-form-item label="创建时间">
      <div class="detail">&nbsp;{{userDetail.createTime}}</div>
    </el-form-item>

    <el-form-item label="创建人">
      <div class="detail">&nbsp;{{userDetail.createByDO.name}}</div>
    </el-form-item>

    <el-form-item label="编辑时间">
      <div class="detail">&nbsp;{{userDetail.editTime}}</div>
    </el-form-item>

    <el-form-item label="编辑人">
      <div class="detail">&nbsp;{{userDetail.editByDO.name}}</div>
    </el-form-item>

    <el-form-item label="最近登录时间">
      <div class="detail">&nbsp;{{userDetail.lastLoginTime}}</div>
    </el-form-item>

    <el-button type="success" @click="back">返回</el-button>
  </el-form>
</template>

<script>
import {doGet} from "../http/httpRequest.js";

export default {
  name: "UserDetailView",
  data(){
    return {
      userDetail:{
        createByDO: {},
        editByDO: {}
      }
    }
  },

  mounted() {
    this.loadUserDetail();
  },

  methods:{
    // 加载用户详情
    loadUserDetail(){
      let id = this.$route.params.id
      doGet('/api/user/'+id,{}).then((resp)=>{
        if (resp.data.code===200){
          console.log(resp)
          this.userDetail=resp.data.data
          if (!this.userDetail.createByDO){
            this.userDetail.createByDO={}
          }
          if (!this.userDetail.editByDO){
            this.userDetail.editByDO={}
          }
        }
      })
    },
    back(){
      this.$router.go(-1)
    }

  }
}
</script>

<style scoped>
.detail {
  background-color: #F0FFFF;
  width: 80%;
  padding-left: 5px;
}
.el-button {
  float: right;
  margin-top: 10px;
}
.el-form-item {
  height: 20px;
}
</style>